m1_mn <- readRDS("temp/mn_model_1.rds")

m1_nc <- readRDS("temp/nc_model_1.rds")
m2_nc <- readRDS("temp/nc_model_2.rds")

m1_wa <- readRDS("temp/wa_model_1.rds")
m2_wa <- readRDS("temp/wa_model_2.rds")

rows <- tribble(~term,          ~m1,  ~m2, ~m3, ~m4, ~m5,
                "Year Fixed Effects", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$", 
                "Voter Fixed Effects", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$")

attr(rows, 'position') <- c(11:12)


modelsummary::modelsummary(list(m1_mn, m1_nc, m2_nc, m1_wa, m2_wa),
                           statistic = "std.error",
                           stars = c("*" = 0.05, "**" = 0.01, "***" = 0.001),
                           coef_map = c("t2TRUE:I(year == 2020)TRUE" = "Household Covid Death × 2020",
                                        "t1TRUE:I(year == 2020)TRUE" = "Household Death × 2020",
                                        "I(year == 2020)TRUE:rep" = "2020 × Republican",
                                        "t2TRUE:I(year == 2020)TRUE:rep" = "Household Covid Death × 2020 × Republican",
                                        "t1TRUE:I(year == 2020)TRUE:rep" = "Household Death × 2020 × Republican"),
                           gof_omit = 'DF|Deviance|AIC|BIC|Within|Pseudo|Log|Std|FE|RMSE',
                           add_rows = rows,
                           title = "\\label{tab:wa-reg-1} Household Deaths and Voter Turnout",
                           notes = list("Standard errors clustered by voter and year."),
                           output = "latex",
                           escape = FALSE) |> 
  add_header_above(c(" " = 1, "Minnesota" = 1, "North Carolina" = 2, "Washington" = 2), align = "c") |> 
  kable_styling(latex_options = c("scale_down")) |>
  save_kable("temp/state_reg.tex")

m1_mn <- readRDS("temp/mn_model_1_dist.rds")

m1_nc <- readRDS("temp/nc_model_1_dist.rds")
m2_nc <- readRDS("temp/nc_model_2_dist.rds")

m1_wa <- readRDS("temp/wa_model_1_dist.rds")
m2_wa <- readRDS("temp/wa_model_2_dist.rds")

rows <- tribble(~term,          ~m1,  ~m2, ~m3, ~m4, ~m5,
                "Year Fixed Effects", "\\checkmark$", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$", 
                "Voter Fixed Effects", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$", "$\\checkmark$")

attr(rows, 'position') <- c(11:12)


modelsummary::modelsummary(list(m1_mn, m1_nc, m2_nc, m1_wa, m2_wa),
                           statistic = "std.error",
                           stars = c("*" = 0.05, "**" = 0.01, "***" = 0.001),
                           coef_map = c("t2TRUE:I(year == 2020)TRUE" = "Household Covid Death × 2020",
                                        "t1TRUE:I(year == 2020)TRUE" = "Household Death × 2020",
                                        "I(year == 2020)TRUE:rep" = "2020 × Republican",
                                        "t2TRUE:I(year == 2020)TRUE:rep" = "Household Covid Death × 2020 × Republican",
                                        "t1TRUE:I(year == 2020)TRUE:rep" = "Household Death × 2020 × Republican"),
                           gof_omit = 'DF|Deviance|AIC|BIC|Within|Pseudo|Log|Std|FE|RMSE',
                           add_rows = rows,
                           title = "\\label{tab:wa-reg-1-dist} Household Deaths and Voter Turnout",
                           notes = list("Standard errors clustered by voter and year."),
                           output = "latex",
                           escape = FALSE) |> 
  add_header_above(c(" " = 1, "Minnesota" = 1, "North Carolina" = 2, "Washington" = 2), align = "c") |> 
  kable_styling(latex_options = c("scale_down")) |>
  save_kable("temp/state_reg_dist.tex")
